var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var a in t) t.hasOwnProperty(a) && (e[a] = t[a]);
    })(e, t);
}, function(e, t) {
    function a() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (a.prototype = t.prototype, 
    new a());
}), a = this && this.__decorate || function(e, t, a, n) {
    var r, o = arguments.length, c = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(e, t, a, n); else for (var i = e.length - 1; 0 <= i; i--) (r = e[i]) && (c = (o < 3 ? r(c) : 3 < o ? r(t, a, c) : r(t, a)) || c);
    return 3 < o && c && Object.defineProperty(t, a, c), c;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("MyScrollView"), s = e("PeakTopRankItemView"), c = e("Global"), l = e("GameData"), d = e("WebManager"), u = e("LoadManager"), p = cc._decorator, h = p.ccclass, f = p.property, g = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.first = null, e.second = null, e.third = null, e.headSprite = null, e.rankLabel = null, 
        e.scoreLabel = null, e.tipsLabel = null, e;
    }
    return i(e, t), e.prototype.doStart = function() {
        var t = this;
        this.scoreLabel.string = l.GD.score.toString(), this.initHead(l.GD.playerData.icon, l.GD.playerData.nickname, l.GD.personIdx), 
        d.default.getInstance().reqMatchRank({
            success: function(e) {
                console.log("reqMatchRank", e), c.G.peakRankData = e.data.data, c.G.peakRankData ? (c.G.peakRankData.matchUserRank && (t.rankLabel.string = c.G.peakRankData.matchUserRank.rank.toString(), 
                t.tipsLabel.string = "（目前第五千名<color=#ffee00>" + c.G.peakRankData.matchUserRank.rank_5000 + "</color>分，第一万名<color=#ffee00>" + c.G.peakRankData.matchUserRank.rank_10000 + "</color>分）"), 
                c.G.peakRankData.rankList && (0 < c.G.peakRankData.rankList.length && t.first.init(c.G.peakRankData.rankList[0]), 
                1 < c.G.peakRankData.rankList.length && t.second.init(c.G.peakRankData.rankList[1]), 
                2 < c.G.peakRankData.rankList.length && t.third.init(c.G.peakRankData.rankList[2]), 
                t.init(c.G.peakRankData.rankList.filter(function(e, t) {
                    return 2 < t;
                }).map(function(e, t) {
                    return {
                        rank: t + 3,
                        openid: e.openid,
                        nickname: e.nickname,
                        headpic: e.headpic,
                        score: e.score
                    };
                })))) : console.log("peakRankData", c.G.peakRankData);
            }
        });
    }, e.prototype.initHead = function(e, t, n) {
        var r = this;
        return console.log("headView url", e, "name", t), new Promise(function(t, a) {
            e && "" != e.trim() || isNaN(n) ? e ? u.default.getInstance().loadImage({
                url: e
            }).then(function(e) {
                r.headSprite && e instanceof cc.Texture2D ? r.headSprite.spriteFrame = new cc.SpriteFrame(e) : cc.log(e), 
                t();
            }).catch(function() {
                a();
            }) : a("无效的url") : c.G.personModelList.some(function(e) {
                return e.id == n;
            }) && u.default.getInstance().loadSpriteFrame({
                url: "image/skin/" + n,
                sprite: r.headSprite,
                success: function() {
                    t();
                },
                fail: function(e) {
                    a(e);
                }
            });
        });
    }, a([ f(s.default) ], e.prototype, "first", void 0), a([ f(s.default) ], e.prototype, "second", void 0), 
    a([ f(s.default) ], e.prototype, "third", void 0), a([ f(cc.Sprite) ], e.prototype, "headSprite", void 0), 
    a([ f(cc.Label) ], e.prototype, "rankLabel", void 0), a([ f(cc.Label) ], e.prototype, "scoreLabel", void 0), 
    a([ f(cc.RichText) ], e.prototype, "tipsLabel", void 0), a([ h ], e);
}(r.default);

n.default = g;